package com.qf.mapper;

import com.github.pagehelper.Page;
import com.qf.pojo.dto.PageUserQueryDTO;
import com.qf.pojo.entity.User;
import com.qf.pojo.vo.PageUserQueryVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {

    /**
     * 根据用户名和密码查询用户
     * @param username
     * @return
     */
    @Select("select * from sys_user where username=#{username}")
    User getUser(String username);


    @Insert("insert into sys_user(username, password, nickname, gender,email, phone, create_time, update_time) " +
        "values(#{username},#{password},#{nickname},#{gender},#{email},#{phone},#{createTime},#{updateTime})")
    void register(User user);

    /**
     * 根据id查询用户
     * @param id
     * @return
     */
    @Select("select * from sys_user where id=#{id}")
    User getUserById(Long id);

    /**
     * 分页查询用户列表
     * @param queryDTO
     * @return
     */
    Page<User> pageQuery(PageUserQueryDTO queryDTO);

    /**
     * 根据id删除用户
     * @param ids
     */
    void deleteUser(List<Long> ids);

    /**
     * 根据id更新用户
     * @param user
     */
    void UpdateById(User user);
}
